package com.atguigu.flink.streamapi.transform;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * Created by Smexy on 2022/11/21
 *
 *  union: 并集
 *      把多个同类型的流合并。
 *
 *      同(相同类型)流合污！
 */
public class Demo5_Union
{
    public static void main(String[] args) {


        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<Integer> ds1 = env.fromElements(1, 2, 3);
        DataStreamSource<Integer> ds2 = env.fromElements(1, 2, 3);
        DataStreamSource<Integer> ds3 = env.fromElements(1, 2, 3);
        DataStreamSource<String> ds4 = env.fromElements("a","b");

        DataStream<Integer> ds5 = ds1.union(ds2, ds3);

        ds4.print();


        try {
                    env.execute();
                } catch (Exception e) {
                    e.printStackTrace();
                }

    }
}
